Unit kernel;

Interface

Uses
multiboot,
console,
pecli;

Procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: DWORD); stdcall;

Implementation

Procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: DWORD); stdcall;[Public , alias: 'kmain'];
Begin
  kclearscreen();
  kwritestr('pekernel: boot');

  If (mbmagic <> MULTIBOOT_BOOTLOADER_MAGIC) Then
    Begin
      kwritestr('  [FAIL]');
      kwritestr('  PANIC! BAD BOOTLOADER!');
      asm
      cli
      hlt
    End;
End
Else
  Begin
    kwritestr('  [OK]');
    xpos := 0;
    ypos += 1;
    kwritestrln('pekernel: memory information');
    kwritestrln('');
    kwritestr('|lower memory  = ');
    kwriteint(mbinfo^.mem_lower);
    kwritestrln('KB');
    kwritestr('|higher memory = ');
    kwriteint(mbinfo^.mem_upper div 1024);
    kwritestrln('MB');
    kwritestr('|total memory  = ');
    kwriteint(((mbinfo^.mem_upper + 1000) div 1024) +1);
    kwritestrln('MB');
    kwritestrln('');
    pecli_start;
  End;

asm
  @loop:
  jmp @loop
End;

End;

End.
